/*
** init_sdl.c for dayday in /home/dd/projs/dayday/srcs/client
** 
** Made by dd
** Login   <alletr_p@epitech.net>
** 
** Started on  Tue Jul 21 23:07:39 2009 dd
** Last update Tue Jul 21 23:29:05 2009 dd
*/

#include <assert.h>

#include "client.h"

int	init_sdl(t_all *all)
{
  int	flags;

  if (SDL_Init(SDL_INIT_VIDEO) == -1)
    return (FAILURE);
  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
  flags = SDL_OPENGL;
  if (all->game.screen.fullscreen == ON)
    flags |= SDL_FULLSCREEN;
  all->game.screen.surface = SDL_SetVideoMode(all->game.screen.width, 
					      all->game.screen.height, 
					      COLOR_PER_PIX, flags);
  if (all->game.screen.surface == NULL)
    {
      SDL_Quit();
      return (FAILURE);
    }
  SDL_WM_SetCaption(SCREEN_TITLE, NULL);
  SDL_EnableKeyRepeat(10, 10);
  return (SUCCESS);
}
